<?php
  // no direct access
  defined( '_JEXEC' ) or die( 'Restricted access' );
  jimport('joomla.application.component.controller');
  
  class InfosController extends JController
  {  
    function display(){
    
      $document =& JFactory::getDocument();
      $view = & $this->getView($this->_name, $document->getType());
      
      $season_division = $this->getModel('seasondivision', 'seasondivisionmodel');
      $season          = $this->getModel('season', 'seasonmodel');
      $division        = $this->getModel('division', 'divisionmodel');
      
      $season_id = JRequest::getVar('id');
      $divisions        = array();
      
      if(!isset($season_id)){
        if($lseason = $season->get_latest())
          $season_id     = $lseason->id;
      }
      
      if($season_id){
        $sds = $season_division->get_by_season_id($season_id);
        foreach($sds as $sd)
          $divisions[$sd->division_id] = $division->get($sd->division_id);
      }
      
      $view->assign("divisions", $divisions);
      $view->display();
    }
    
  }
?>